<!doctype html>
<html>

<head>
	<meta charset="UTF-8">
	<meta name="copyright" content="www.apicloud.com" />
	<meta name="viewport" content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
	<title>舆情处置中</title>
	<link rel="stylesheet" type="text/css" href="../css/api.css" />

	<style>
		html {
			height: 100%;
		}

		body {
			height: 100%;
			width: 100%;
		}

		input {
			height: 50px;
			font-size: 18px;
			color: #8E8C8C;
			width: 80%;
		}

		input::-webkit-input-placeholder {
			color: #ccc;
		}
		/* 头部样式 */

		#header {
			border-bottom: 1px solid #8E8C8C;
		}

		.topbar {
			height: 50px;
			border-bottom: 1px solid #DDDFE3;
		}

		#title {
			color: #333;
		}

		.back {
			float: left;
			padding-right: 30px;
		}

		.back img {
			height: 30px;
			margin-top: 10px;
			margin-left: 10px;
			margin-bottom: 10px;
		}

		.topbar .title {
			line-height: 50px;
			font-size: 20px;
			position: absolute;
			left: 50%;
			-webkit-transform: translateX(-50%);
			transform: translateX(-50%);
		}
		/* 内容样式 */

		#main {
			width: 100%;
			height: 100%;
			margin: 0px;
			padding: 0px;
		}

		#main .select {
			width: 100%;
			text-align: left;
			font-size: 1.3em;
			color: #333;
		}

		#main .option {
			width: 90%;
			margin: 0px 5%;
			margin-top: 20px;
			font-weight: bold;
		}

		.condition {
			width: 90%;
			margin: 10px 5%;
			padding: 0px;
			font-size: 1em;
		}

		.condition>ul {
			line-height: 36px;
		}

		.condition>ul>li {
			width: 100%;
			text-indent: 1em;
		}

		.condition .right {
			float: right;
			margin-right: 5%;
			display: none;
		}

		#measures {
			width: 95%;
			margin: 5px 5px 5px 5px;
			border: 1px solid #e0e0e0;
			border-radius: 5px;
			padding: 2px;
			line-height: 26px;
		}
		/*.email, .passwd, .btn {margin:3px 10px;}*/

		.btn {
			margin: 3px 10px;
		}

		.btn {
			background: #3A8B7A;
			color: #fff;
			height: 40px;
			text-align: center;
			line-height: 40px;
			font-size: 20px;
			border-radius: 5px;
		}
		/* 底部样式 */

		.bottom {
			/*position: absolute;bottom: 0;*/
			width: 100%;
			height: 50px;
			text-align: center;
			/*padding-bottom: 20px;*/
			font-size: 12px;
		}

		input {
			outline: none;
		}
	</style>
</head>

<body>
	<div class="top">
		<div id="main">
			<div class="select" style="background-color:#fff">
				<div class="option">转办至(必选)：</div>
				<div class="condition">
					<input type="hidden" id="area" name="area" value="0">
					<ul id="ul_area_user_list">
					</ul>
				</div>
				<div class="option">处置建议(非必选)：</div>
				<div class="condition" style="text-align:center;width: 95%; margin:10px 10px;">
					<textarea style="overflow:scroll;font-size:16px;" id="measures" name="measures" cols="28%" rows="8"></textarea>
				</div>
			</div>
		</div>
		<div id="clear_5"></div>
		<div class="btn" tapmode="buyhover" onclick="goto_SubmitDataFun()">提 交</div>
		<div style="font-size:14px;margin:5px">
			1、转办至：必选项。选择此项，将会把舆情转发到对应的处置人进行处置。若处置人为空说明还未设置相应处置人。
			<br> 2、处置建议：非必填项，填写舆情处置的指导建议。
		</div>
	</div>
	<div class="bottom">

	</div>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/alpenlicebe.js"></script>
<script type="text/javascript" src="../script/zepto.min.js"></script>
<script type="text/javascript" src="../script/hashes.min.js"></script>
<script type="text/javascript">
	apiready = function() {
		var infoID = api.pageParam.infoID;
		if ('' == infoID || undefined == infoID || null == infoID) {
			api.alert({
				title: '系统提示',
				msg: '参数错误3'
			});
			return;
		}
		/*加载地区*/
		goto_loadAreaListFun();
	}

	function goto_loadAreaListFun() {

		api.showProgress({
			style: 'default',
			animationType: 'fade',
			title: '',
			text: '',
			modal: false
		});

		var MD5 = new Hashes.MD5;
		var access_token = Alpe_getLocalStorge("access_token");
		var admin_id = Alpe_getLocalStorge("admin_id");
		var sign = MD5.hex(access_token + admin_id + 'datas/GetAreaUser1.0syjqingbao');

		var url = Alpe_ApiUrl + 'r=datas/GetAreaUser&access_token=' + access_token + '&admin_id=' + admin_id +
			'&v=1.0&sign=' + sign;
		console.log(url);
		api.ajax({
			url: url,
			method: 'get',
			cache: false,
			timeout: 30,
			dataType: 'json'
		}, function(ret, err) {
			if (ret) {
				if ("100" == ret.success) {
					for (var idx in ret.list) {
						var module = ret.list[idx];
						var area_id = module["area_id"];
						var area_name = module["area_name"];
						var listHtml = "<li id='selected_" + area_id + "' onclick='openSelect(" + area_id + ")'>" + area_name + "<b id='duigou_" + area_id + "' class='right'>√</b></li>";
						$("#ul_area_user_list").append(listHtml);
					}
					api.hideProgress();
				} else {
					api.alert({
						title: '系统提示',
						msg: ret.message
					});
					api.hideProgress();
				}
			} else {
				api.alert({
					title: '系统提示',
					msg: '错误码：' + err.code + '；错误信息：' + err.msg + '网络状态码：' + err.statusCode
				});
				api.hideProgress();
			}
		});
	}

	//打开地区选择
	function openSelect(id) {
		//将之前选中的样式复原
		var selected_id = document.getElementById('area').value;
		if (selected_id != "0") {
			document.getElementById('duigou_' + selected_id).style.display = "none";
			document.getElementById('selected_' + selected_id).style.background = "#fff";
			document.getElementById('selected_' + selected_id).style.color = "#333";
		}

		//标记处已选中的样式
		if (id != selected_id) {
			document.getElementById('duigou_' + id).style.display = "block";
			document.getElementById('selected_' + id).style.background = "#e0e0e0";
			document.getElementById('selected_' + id).style.color = "#3A8B7A";

			//输出已选中的
			document.getElementById('area').value = id;
		} else {
			document.getElementById('area').value = "0";
		}
	}

	function goto_SubmitDataFun() {
		var infoID = api.pageParam.infoID;
		if ('' == infoID || undefined == infoID || null == infoID) {
			api.alert({
				title: '系统提示',
				msg: '参数错误4'
			});
			return;
		}
		var measures = $("#measures").val();
		var area = $("#area").val();
		var deal_status = "1";
		var feedback = "";
		var is_media = "";
		var isreal = "";
		if('0'==area){
		  	api.alert({title:'系统提示',msg:'请检查必选项'});
				return;
    }
		// if ('' == measures) {
		// 	api.alert({
		// 		title: '系统提示',
		// 		msg: '请填写“处置措施”'
		// 	});
		// 	return;
		// }
		api.confirm({
			title: '确认是否提交',
			msg: '提交成功后将返回原信息页面，可返回列表查看提交信息。',
			buttons: ['确定', '取消']
		}, function(ret, err) {
			if (ret.buttonIndex == 1) {
				api.showProgress({
					style: 'default',
					animationType: 'fade',
					title: '',
					text: '',
					modal: false
				});

				var MD5 = new Hashes.MD5;
				var access_token = Alpe_getLocalStorge("access_token");
				var admin_id = Alpe_getLocalStorge("admin_id");
				var sign = MD5.hex(access_token + admin_id + infoID + 'datas/setDeal1.0syjqingbao');

				/*var url = Alpe_ApiUrl+'r=datas/setDeal&access_token='+access_token+'&admin_id='+admin_id
					+'&message_id='+infoID
					+'&feedback='+feedback
					+'&is_media='+is_media +'&isreal='+isreal
					+'&area_id='+area +'&deal_status='+deal_status
					+'&measures='+measures +'&deal_result='+measures
					+'&v=1.0&sign='+sign;*/
				var url = Alpe_ApiUrl + 'r=datas/setDeal&access_token=' + access_token + '&admin_id=' + admin_id +
					'&message_id=' + infoID +
					'&is_media=' + is_media + '&isreal=' + isreal +
					'&area_id=' + area + '&deal_status=' + deal_status +
					'&v=1.0&sign=' + sign;
				var pap = {
					feedback: feedback,
					measures: measures,
					deal_result: measures
				};
				api.ajax({
					url: url,
					method: 'post',
					cache: false,
					returnAll: false,
					data: {
						values: pap
					},
					dataType: 'json'
				}, function(ret, err) {
					if (ret) {
						api.hideProgress();
						api.toast({
							msg: ret.message,
							duration: 2000,
							location: 'middle'
						});
						if (ret.success == "101") {
							/*注册已经处理的事件，刷新详细页面*/
							api.sendEvent({
								name: 'Alpe_Event_yq_dosomething',
								extra: {
									keyID: 'alpenlicebe'
								}
							});
							setTimeout(function() {
								api.closeWin();
							}, 3000);
						}
					} else {
						api.alert({
							title: '系统提示',
							msg: '错误码：' + err.code + '；错误信息：' + err.msg + '网络状态码：' + err.statusCode
						});
						api.hideProgress();
					}
				});
			}
		});
	}
</script>

</html>
